//存储接收人的ID
var receiverIds = new Array();
var receiveNames = new Array();


function add(id,nickname){
	// 往收件栏里添加
	if(receiverIds.contains(id)==true){
		$("#nicknamequery").val("");
		alert("该联系人已添加");
		return;
	}
	
	var userId = $("#userId").val();
	if(id==userId){
		$("#nicknamequery").val("");
		alert("不能给自己发送消息");
		return;
	}
	
	var str = "<ul class='send-model'>" +
				"<li class='name'>" + nickname + "</li>" +
				"<input type='hidden' value='" + id + "' />" +
				"<li class='operate-d delete-receiver'></li> " +
			"</ul>";
	$("#receiveNicknames").append(str);
	
	receiverIds.push(id);
	receiveNames.push(nickname);
	
	
	// 清空
	$("#nicknamequery").val("");
	$(".delete-receiver").click(function() {
		var removeId = $(this).prev().val();
		var removeName = receiveNames[receiverIds.indexOf(removeId)];
		//再移除
		receiverIds.remove(removeId);
		receiveNames.remove(removeName);
		$(this).parent().remove();
	});
}